//
//  SFEmoticon.m
//  SFEmoticon
//
//  Created by 许博 on 16/7/18.
//  Copyright © 2016年 许博. All rights reserved.
//

#import "SFEmoticon.h"
#import "NSBundle+SFEmoticon.h"
#import "NSString+SFEmoji.h"

@implementation SFEmoticon
#pragma mark - 计算型属性
- (NSString *)imagePath {
    
    if (_type == 1) {
        return nil;
    }
    
    return [NSString stringWithFormat:@"%@/%@", _directory, _png];
}

- (void)setCode:(NSString *)code {
    _emoji = code.sf_emoji;
}

- (BOOL)isEmoji {
    return _emoji != nil;
}

#pragma mark - 构造函数
+ (instancetype)emoticonWithDict:(NSDictionary *)dict {
    id obj = [[self alloc] init];
    
    [obj setValuesForKeysWithDictionary:dict];
    
    return obj;
}

- (void)setValue:(id)value forUndefinedKey:(NSString *)key {}

- (NSString *)description {
    NSArray *keys = @[@"type", @"chs", @"png", @"code", @"times"];
    return [self dictionaryWithValuesForKeys:keys].description;
}

#pragma mark - 公共方法
- (NSDictionary *)dictionary {
    NSArray *keys = @[@"type", @"chs", @"directory", @"png", @"code", @"times",@"gif"];
    
    return [self dictionaryWithValuesForKeys:keys];
}
@end
